/*
 * CellModel.h
 *
 *      Author: Jerome RD Soine and Christoph A Brand
 *      Institution: Schwarz goup, Institute for Theoretical Physics, Heidelberg University, Germany
 */

#ifndef CELLMODEL_H_
#define CELLMODEL_H_

#include <vector>
#include "ForceTransmission.h"

using namespace std;

/*!
 *  \brief Abstract class for developing a custom model for cellular forces.
 *
 *  This is the basic abstract class for which a specific implementation must be inherited. It contains basic
 *  functions and object associated with a general cell model.
 */

class CellModel{

protected:
	/*!
	 * Vector that contains the current model parameter configuration
	 * */
	vector<double> parameters;
	/*!
	 * The ForceTransmission object vector associated with the cell model.
	 * It determines the traction application to the substrate model.
	 */
	vector<ForceTransmission*> force_transmissions;

public:
	/*!
	 * Abstract class destructor
	 */
	virtual ~CellModel() {};
	/*!
	 * This function needs to be implemented in order to clone cell model objects.
	 * This function is heavily used by Worker.h to provide multi-threading.
	 * Clones should not use the same memory resources as the template.
	 */
	virtual CellModel * clone() const = 0;
	/*!
	 * This function contains the entire model force calculation process. This is the key logic the cell model has to provide.
	 *
	 */
	virtual void run() = 0;
	/*!
	 * This function can be implemented optionally by a derived cell model. It can be used to provide further
	 * configurations parameters for the model e.g. the initial vertex positions in a network model.
	 */
	virtual void set_initial_configuration(vector<double> init_config) {};
	/*!
	 * Returns the final configuration of the model, e.g. final vertex positions of a network model.
	 */
	virtual vector<double> get_final_configuration() { return vector<double>(0); };
	/*!
	 * Returns the current model parameters.
	 */
	virtual vector<double> get_parameters(){ return parameters; };
	/*!
	 * Sets the current model parameters.
	 */
	virtual void set_parameters(vector<double> param) { parameters = param; };
	/*!
	 * Returns the number of model parameters.
	 */
	unsigned int n_parameters(){ return parameters.size(); };
	/*!
	 * Returns the force transmission object belonging to the cell model. Must be available after a call of run().
	 */
	virtual vector<ForceTransmission*> get_force_transmissions(){ return force_transmissions; };
	/*!
	 * Returns the sum of all absolute forces stored in force_transmissions
	 */
	virtual double get_total_force() {
		double total_force = 0;
		for(unsigned int i=0; i<force_transmissions.size(); i++){
			total_force += force_transmissions[i]->get_force_magnitude();
		}
		return total_force;
	};
};


#endif /* CELLMODEL_H_ */
